class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-07-07",
      revision: "1514ca02a7aa83dfe897dd3e8a26d275d9858647"
  version "2021-07-07"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "acef5d1929ea54042cf25265c4303ee6624b2418510cf6b9bf95eff2b8dcc558"
    sha256 cellar: :any_skip_relocation, big_sur:       "8d3924cc101671df55f7d6f21140da0218a93e86d4007c2d85a170155509be0c"
    sha256 cellar: :any_skip_relocation, catalina:      "699763a1b058a44b0fffe310ac5eedbd5f9bf5e551ab93b8fe346d0572c0325e"
    sha256 cellar: :any_skip_relocation, mojave:        "921e43929ae9581cdbffcb50dd6363a88a5bc1e359e1a37fb7271ff0f99b4224"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
